package com.hhf.springboot.model.vo;

import com.hhf.springboot.model.entity.ServiceProject;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.Date;

/**
 * 服务项目信息视图
 *
 * @author hhf
 * @from <a href="https://gitee.com/hanhuaifei/projects">我的gitee</a>
 * @Date 2024/9/26
 */
@Data
public class ServiceProjectVO implements Serializable {

    /**
     * id
     */
    private Long id;

    /**
     * 标题
     */
    private String title;

    /**
     * 介绍文档
     */
    private String introduce;

    /**
     * 服务价格（单位：分）
     */
    private Integer price;

    /**
     * 服务项目展示图片
     */
    private String cover;

    /**
     * 访问数
     */
    private Long clickNum;

    /**
     * 状态(0-关闭,1-开启)
     */
    private Integer status;

    /**
     * 用户id
     */
    private Long userId;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新时间
     */
    private Date updateTime;


    private static final long serialVersionUID = 1L;

    /**
     * 创建用户信息
     */
    private UserVO user;

    /**
     * 封装类转对象
     *
     * @param serviceProjectVO
     * @return
     */
    public static ServiceProject voToObj(ServiceProjectVO serviceProjectVO) {
        if (serviceProjectVO == null) {
            return null;
        }
        ServiceProject serviceProject = new ServiceProject();
        BeanUtils.copyProperties(serviceProjectVO, serviceProject);
        return serviceProject;
    }

    /**
     * 对象转封装类
     *
     * @param serviceProject
     * @return
     */
    public static ServiceProjectVO objToVo(ServiceProject serviceProject) {
        if (serviceProject == null) {
            return null;
        }
        ServiceProjectVO serviceProjectVO = new ServiceProjectVO();
        BeanUtils.copyProperties(serviceProject, serviceProjectVO);
        return serviceProjectVO;
    }
}
